package com.kayden.ioc.component;

import com.kayden.ioc.model.Student;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

@Component
public class StudentComponent {

    @Primary//指定该bean为默认bean的实现
    @Bean({"s3","s4"})
    //@Bean(name = {"s3", "s4"})  //三个都一个意思
    //@Bean(value = {"s3", "s4"})
    public Student s1(){
        return new Student("zhangsan",11);
    }

    @Bean
    public String name(){
        return  "lisi";
    }

    @Bean
    public  String name2(){
        return "lisi2";
    }

//    @Bean
//    public Student s2(String name){
//        return new Student(name,18);
//    }

    @Bean
    public Student s2(@Qualifier("name")String n){//指定bean名称
        return new Student(n,18);
    }



}
